package com.yzl.meeting.framework.context;

import com.yzl.meeting.framework.beans.factory.BeanFactoryImpl;
import com.yzl.meeting.framework.beans.factory.xml.XmlBeanDefinitionReader;
import com.yzl.meeting.framework.core.io.Resource;

/**
 * @Title: XmlApplicationContext
 * @Author: 姚志立
 * @Description:
 * @Date: 2020/10/21 9:51
 * @Version: 1.0
 */
public abstract class AbstractApplicationContext {

    BeanFactoryImpl factory;
    public  AbstractApplicationContext(String fileName) {
        factory = new BeanFactoryImpl();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        Resource resource = getPathResource(fileName);
        reader.loadConfigurationFile(resource);
    }

    protected abstract Resource getPathResource(String fileName);

    public Object getBean(String beanId) {
        return factory.getBean(beanId);
    }
}
